import {$get, $post, $put} from '@js/request'
import {ServiceSchema} from '@components/schema/service'

export async function getServiceListRequest(topicid: string): Promise<ServiceSchema[]> {
  const res = await $get('/api/commission/deliver', {
    topicid
  })
  const l: ServiceSchema[] = res.data
  l.forEach((li, i) => {
    li.order = i + 1
  })
  return l
}

// 更新送达数据
export async function updateModalData (id: string, data: { [k: string]: any }) {
  const res = await $put(`/api/commission/deliver/${id}`, data)
  return res.data
}

export async function getDetailRequest (id: string): Promise<ServiceSchema> {
  const res = await $get(`/api/commission/deliver/${id}`)
  return res.data
}

export async function sendElectronicRequest (deliverid: string) {
  const res = await $put('/api/commission/deliver/sendDigitalDeliver', {
    deliverid
  })
  return res.data
}

export async function createFile (bizid: string, caseid: string): Promise<string> {
  const res = await $post('/api/commission/document/createByKeys', {
    bizid,
    caseid,
    filecodes: 'dianzisongdaguiji'
  })
  return res.data
}
